home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
serien
/
purity
/
nr.10
/
medplayerlibrary
/
medplay1.0d.p
< prev
next >
Wrap
Text File
|
1995-04-19
|
6KB
|
290 lines
program medplay4;
{ This example uses medplayer.library. Use PCQ-Pascal V1.2 }
{$I "Include:Libraries/medplayer.i" }
{$I "Include:libraries/dos.i" }
{$I "Include:exec/Libraries.i" }
{$I "Include:exec/memory.i" }
{$I "Include:utils/Parameters.i" }
{$I "Include:utils/Stringlib.i" }
{$I "Include:intuition/intuition.i" }
{$I "Include:diesel/MyFReq2.i" }
{$I "Include:diesel/AutoReq.i" }
Const
NumGads = 5;
NewWin : NewWindow = ( 0,20,315,30, 0,2, CloseWindow_f+GadgetUp_f,
WindowDrag+WindowDepth+WindowClose+RMBTrap,
NIL, NIL, NIL,NIL, NIL,
0,0,0,0, WBenchScreen_f);
RawGad : Gadget = ( NIL, 0,14, 46,11, GadgHBox, RelVerify,
boolgadget, NIL, NIL, NIL, 0, NIL, 0, NIL );
RawTxt : IntuiText = ( 2,0, jam1, 4,2, NIL, NIL, NIL );
GadTxt : Array[0..NumGads-1] of String = ("Load",
" New",
"Start",
"Stop",
"Cont");
Type
gadarr = Array[0..NumGads-1] of Gadget;
txtarr = Array[0..NumGads-1] of IntuiText;
gadArrPtr = ^GadArr;
txtArrPtr = ^txtarr;
VAR
WB : WBStartupPtr;
gads1,
gads2 : GadArrPtr;
txts1,
txts2 : txtarrPtr;
slect : GadgetPtr;
home,
sea : FileLock;
i : Short;
res,
MpDir,
MpFile,
MpPath,
name : String;
gp,
class : Integer;
module1,
module2 : MMD0Ptr;
Win : WindowPtr;
WMsgPort : MsgPortPtr;
Msg : IntuiMessagePtr;
buf : Array[0..99] of Char;
{ --------------------------------------------------------------------- }
PROCEDURE CleanExit( why : String; rt : Integer);
BEGIN
IF Win <> NIL THEN CloseWindow( Win );
IF gp = 0 THEN FreePlayer;
IF module1 <> NIL THEN UnloadModule( module1 );
IF ReqBase <> NIL THEN CloseLibrary( ReqBase );
IF MEDPlayerBase <> NIL THEN CloseLibrary( MEDPlayerBase );
IF home <> NIL THEN home := CurrentDir( home );
IF why <> NIL THEN
BEGIN
write( why );
Delay(50);
END;
Exit( rt );
END;
{ --------------------------------------------------------------------- }
FUNCTION ReqAFile: String; { NIL zurück -> OK }
Var
ok : Integer;
BEGIN
IF ReqBase <> NIL THEN BEGIN
ok := FileReq( "Medplay 1.0d (C)93/Diesel", MpDir, MpFile, MpPath );
IF ok <> 0 THEN ReqAFile := "Error on requesting file !\n";
strcpy( name, MpPath );
ReqAFile := NIL;
END ELSE BEGIN
IF SysReq("Konnte req.library nicht laden","Schade","Schade")THEN;
ReqAFile := "Sorry, no req.library\n";
END;
END;
{ --------------------------------------------------------------------- }
PROCEDURE OpentheWindowETC;
BEGIN
New( gads1 ); gads2 := gads1;
New( txts1 ); txts2 := txts1;
For i := 0 to NumGads-1 do BEGIN
CopyMem( Adr(RawTxt), Adr(txts1^[i]), SizeOf(IntuiText) );
txts1^[i].IText := gadtxt[i];
gads2 := Address( Integer(gads2) + SizeOf(Gadget) );
CopyMem( Adr(RawGad), Adr(gads1^[i]), SizeOf(Gadget) );
With gads1^[i] do BEGIN
GadgetID := i + 1;
leftEdge := 12 + i * 60;
nextGadget := GadgetPtr( gads2 );
GadgetText := Adr( txts1^[i] );
END;
END;
gads1^[NumGads-1].NextGadget := NIL;
NewWin.Title := name;
NewWin.FirstGadget := GadgetPtr( gads1 );
Win := OpenWindow( Adr(NewWin) );
IF Win = NIL THEN CleanExit("Cannot open window\n",0);
END;
{ --------------------------------------------------------------------- }
BEGIN
gp := -1;
home := NIL;
name := AllocString( 162 );
MpDir := AllocString( 131 );
MpFile := AllocString( 31 );
MpPath := AllocString( 162 );
MpDir[0] := chr(0);
MpFile[0] := chr(0);
MpPath[0] := chr(0);
MEDPlayerBase := OpenLibrary( medname, 0 );
IF MEDPlayerBase = NIL THEN
CleanExit("Cannot open medplayer.library\n", 10);
ReqBase := OpenLibrary("req.library",0);
WB := GetStartupMsg();
IF WB <> nil THEN BEGIN
IF WB^.sm_NumArgs > 1 THEN BEGIN
strcpy( name, WB^.sm_ArgList^[2].wa_Name );
END ELSE BEGIN
res := ReqAFile;
END;
home := CurrentDir( WB^.sm_ArgList^[2].wa_Lock );
END ELSE BEGIN
GetParam( 1, name );
IF name[0]= chr(0) THEN
CleanExit("Medplay 1.0d, 1993 by Diesel\nUsage: Medplay med-modulename\n\n",0);
strcpy( MpPath, name );
END;
gp := GetPlayer(0);
IF ( gp <> 0 ) THEN
CleanExit("Cannot init player\n",0);
IF name[0] <> chr(0) THEN BEGIN
module1 := LoadModule( name );
IF module1 = NIL THEN
CleanExit("Cannot load module\n",0);
END;
OpentheWindowETC;
IF module1 <> NIL THEN PlayModule(module1);
WMsgPort:=Win^.UserPort; { MsgPort holen }
REPEAT
REPEAT
Msg := IntuiMessagePtr( WaitPort( WMsgPort ));
Msg := IntuiMessagePtr( GetMsg( WMsgPort ));
UNTIL Msg <> NIL ;
class := Msg^.class;
slect := GadgetPtr( Msg^.iAddress );
ReplyMsg( MessagePtr( Msg ) ); { OK to sender }
CASE class OF
GADGETUP_F :
BEGIN
CASE Slect^.GadgetID OF
1 : BEGIN
IF ReqAFile <> NIL THEN
DisplayBeep(NIL)
ELSE BEGIN
module2 := LoadModule( name );
IF module2 = NIL
THEN DisplayBeep(NIL)
ELSE BEGIN
DimOffPlayer( 15 );
Delay(100);
IF module1<>NIL THEN UnloadModule( module1 );
module1 := module2;
PlayModule( module1 );
module2 := NIL;
END;
END;
END;
2 : BEGIN
IF module1 <> NIL THEN BEGIN
StopPlayer;
UnloadModule( module1 );
module1 := NIL;
IF ReqAFile <> NIL THEN BEGIN
DisplayBeep(NIL);
END ELSE BEGIN
module1 := LoadModule( name );
IF module1 = NIL
THEN DisplayBeep(NIL)
ELSE PlayModule( module1 );
END;
END;
END;
3 : BEGIN
PlayModule( module1 );
END;
4 : BEGIN
StopPlayer;
END;
5 : BEGIN
ContModule( module1 );
END;
ELSE END;
END;
ELSE END;
UNTIL class = CLOSEWINDOW_f;
REPEAT
Msg:=IntuiMessagePtr(GetMsg(WMsgPort)); { Msg holen, = NIL ? }
IF Msg <> NIL THEN
ReplyMsg(MessagePtr(Msg)); { Msg beantworten }
UNTIL Msg = NIL;
CloseWindow( Win );
Win := NIL;
DimOffPlayer(12);
Delay(100);
CleanExit( NIL, 0 );
END.